package com.kfm.base.date.d0825.am;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;

public class Demo02 {

    public static void main(String[] args) {
        /*
            LocalDate jdk8 新增的 表示日期对象
         */
        // 当前日期的 LocalDate 对象
        LocalDate date = LocalDate.now();

        // 指定日期的 LocalDate 对象
        LocalDate date1 = LocalDate.of(2023, 8, 25);

        LocalDate date2 = LocalDate.ofYearDay(2023, 237);

        System.out.println(date);
        System.out.println(date1);
        System.out.println(date2);


        DayOfWeek dayOfWeek = date.getDayOfWeek();
        System.out.println(dayOfWeek);

        // a % b = a & (b - 1)  其中 b 是 2 的幂
        boolean leapYear = date.isLeapYear();
        System.out.println(leapYear);

        int i = date.lengthOfYear();
        System.out.println(i);

        System.out.println(date.lengthOfMonth());

        date.plusDays(1);

        date.minusDays(1);

        // 1 s = 1000 ms = 1000 * 1000 微秒 = 1000 * 1000 * 1000 纳秒(ns)

        LocalDateTime ldf = LocalDateTime.now();

        String str = ldf.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        System.out.println(str);

        Month month = ldf.getMonth();
        int monthValue = ldf.getMonthValue();
        System.out.println(month);
        System.out.println(monthValue);

        LocalDateTime parse = LocalDateTime.parse("2023-08-25T11:28:29");
        System.out.println(parse);


    }
}
